/**
 * @ClassName LC82
 * @Author ykx
 * @Date 2024/3/23 11:38
 * @Version 1.0
 */
public class LC82 {
    public static void main(String[] args) {
        LC82 lc82 = new LC82();
        int[] nums = new int[]{1, 1}; // 2,5,6
        ListNode listNode = ListNode.setData(nums);
        System.out.println(lc82.deleteDuplicates(listNode));
    }

    public ListNode deleteDuplicates(ListNode head) {
        ListNode result = new ListNode(0);
        ListNode dummyHead = result;
        while (head != null) {
            if (head.next != null && head.val == head.next.val) {
                int val = head.val;
                while (head != null && val == head.val) {
                    head = head.next;
                }
            } else {
                result.next = new ListNode(head.val);
                result = result.next;
                head = head.next;
            }
        }
        return dummyHead.next;
    }
}
